package com.tcheung.service;

import java.util.HashMap;
import java.util.Map;

/**
 * 答案查询service
 * 讲老师给出的answer.doc存储起来，方便查询
 *
 * @author: zhangteng
 * @time: 2015/1/2 11:36
 */
public class AnswerService {

    private static AnswerService instance = null;

    private static Map<Integer, Integer> answerMap = new HashMap<Integer, Integer>();

    public static AnswerService getInstance() {
        if (instance == null) {
            instance = new AnswerService();
        }
        return instance;
    }

    private AnswerService() {
        init();
    }

    private void init() {
        answerMap.put(1, 1);
        answerMap.put(2, 2);
        answerMap.put(3, 2);
        answerMap.put(4, 3);
        answerMap.put(5, 3);
        answerMap.put(6, 4);
        answerMap.put(7, 4);
        answerMap.put(8, 5);
        answerMap.put(9, 6);
        answerMap.put(10, 7);
        answerMap.put(11, 8);
        answerMap.put(12, 9);
        answerMap.put(13, 9);
        answerMap.put(14, 10);
        answerMap.put(15, 11);
        answerMap.put(16, 11);
        answerMap.put(17, 12);
        answerMap.put(18, 13);
        answerMap.put(19, 14);
        answerMap.put(20, 15);
        answerMap.put(21, 15);
        answerMap.put(22, 16);
        answerMap.put(23, 17);
        answerMap.put(24, 18);
        answerMap.put(25, 19);
        answerMap.put(26, 20);
        answerMap.put(27, 21);
        answerMap.put(28, 22);
        answerMap.put(29, 23);
        answerMap.put(30, 24);
        answerMap.put(31, 25);
        answerMap.put(32, 26);
        answerMap.put(33, 27);
        answerMap.put(34, 28);
        answerMap.put(35, 29);
        answerMap.put(36, 30);
    }

    public int getAnswerByQueryNum(int queryNum) {
        if (answerMap.containsKey(queryNum)) {
            return answerMap.get(queryNum);
        }
        return 0;
    }
}
